Class
MODULAR
PROGRAMMING
int i, j, k; /*
Define three integers */
i = 1; /* Assign 1 to integer i */
j = 2; /* Assign 2 to integer j */
k = i + j; /* Assign the sum of i and
j to k */
Consider the ADT Integer. Outline the relationship
to the ADT Integer in the following
code:
class Integer {
attributes:
int i, j
methods:
setValue(int n)
Integer addValue(Integer j,
Integer i)
}
A class is the
implementation of an abstract data type (ADT). It defines attributes and methods which
implement the data structure and operations of the
ADT, respectively. Instances of classes are called objects.
Consequently, classes define properties and behaviour of sets
of objects.